import { $get } from '@js/request'
import { CourtSchema } from '@src/components/schema/court';
import { CaseSchema } from '@src/components/schema/caseSchema';

export async function getDataRequest (day: string, id: string): Promise<CourtSchema[]> {
  const res = await $get('/api/commission/hearingroombook/day', {
    day,
    operatorid: id
  })
  return res.data
}

export async function getCaseListRequest (employeeid: string): Promise<CaseSchema[]> {
  const condition = [{ k: 'processerid', o: '=', v: employeeid }]
  const res = await $get('/api/commission/case', {
    page: 1,
    limit: 8,
    condition: JSON.stringify(condition)
  })
  return res.data.list
}

export async function getCourtListRequest (begintime: number, endtime: number, operatorid: string): Promise<string[]> {
  const res = await $get('/api/commission/hearingroombook/datecount', {
    begintime,
    endtime,
    operatorid
  })
  const d: Array<{[k: string]: string}> = res.data
  return d.map(li => li.date)
}
